package com.egao.common.manage.student;

import com.egao.common.core.annotation.OperLog;
import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.common.module.pepesi.entity.vo.PepsiStudentVO;
import com.egao.common.module.pepesi.service.PepsiStudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


/**
 * @author pyx
 */
@Api(tags = "学生的100件事")
@RestController
@RequestMapping("${api}")
public class StudentPepsiController extends BaseController {
    @Autowired
    private PepsiStudentService pepsiStudentService;

    @PreAuthorize("hasAuthority('student')")
    @ApiOperation("查询学生100件事")
    @OperLog(value = "学生的100件事", desc = "查询学生的100件事树形结构")
    @GetMapping("/student/pepsi/tree")
    public JsonResult page(Integer finishState) {
        return pepsiStudentService.pepsiStudentData(getLoginUserId(),finishState);
    }

    @PreAuthorize("hasAuthority('student')")
    @OperLog(value = "学生的100件事", desc = "提交信息", result = true)
    @ApiOperation(value = "提交100件事信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "studentFormVO", value = "StudentFormVO", required = true, dataType = "StudentFormVO")
    })
    @PutMapping("/student/pepsi/update")
    public JsonResult update(@RequestBody PepsiStudentVO pepsiStudentVO) {

        return pepsiStudentService.updatePepsi(pepsiStudentVO);
    }

    @PreAuthorize("hasAuthority('student')")
    @OperLog(value = "学生的100件事", desc = "详情信息")
    @ApiOperation(value = "详情信息", notes = "")
    @GetMapping("/student/pepsi/detail")
    public JsonResult detail(Integer id) {
        return JsonResult.ok().setData(pepsiStudentService.getId(id));
    }
}
